// // Created by lfm on 25-4-8.

#include <iostream>
#include "MyArray.hpp"
using namespace std;

void printArray(MyArray<int>& arr)
{
    for (int i = 0; i < arr.getSize(); i++)
    {
        cout << arr[i] << endl;
    }
}
void test01()
{
    MyArray<int> arr1(5);

    for (int i = 0; i < 5; i++)
    {
        //利用尾插法向数组中插入数据
        arr1.Push_Back(i);
    }
    cout << "arr1的打印输出为：" << endl;
    printArray(arr1);
    cout << "arr1的容量为：" << arr1.GetCapacity() << endl;
    cout << "arr1的大小为：" << arr1.getSize() << endl;

    MyArray<int> arr2(arr1);

    cout << "arr2的打印输出为：" << endl;
    printArray(arr2);
    //尾删
    arr2.Pop_Back();

    cout << "arr2的容量为：" << arr2.GetCapacity() << endl;
    cout << "arr2的大小为：" << arr2.getSize() << endl;
}
//测试自定义类型
class Person
{
public:
    Person()
    {}
    Person (string name, int age):m_Name(name), m_Age(age)
    {}
public:
    string m_Name;
    int m_Age;
};
void printPerson(MyArray<Person> &arr)
{
    for (int i = 0; i < arr.GetCapacity(); i++)
    {
        cout << "姓名：" << arr[i].m_Name <<  "年龄" << arr[i].m_Age << endl;
    }
}
void test02()
{
    MyArray<Person> arr(10);
    Person p1("sunwukong", 999);
    Person p2("dsfk", 53);
    Person p3("fsdkfhk", 423);
    Person p4("dshjdk", 35);
    Person p5("fdskf", 7483);
    Person p6("fds", 482395);
    arr.Push_Back(p1);
    arr.Push_Back(p2);
    arr.Push_Back(p3);
    arr.Push_Back(p4);
    arr.Push_Back(p5);
    arr.Push_Back(p6);

    //打印数组
    printPerson(arr);
}

int main()
{
    // test01();
    test02();
    return 0;
}
